<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
		<script type="text/javascript" src="../js/vue.min.js" ></script>
	</head>
	<body>
		<div id="app">
			<input type="text" v-model="n1">
			
			<select v-model="xuanze">
				<option value="+">+</option>
				<option value="-">-</option>
				<option value="*">*</option>
				<option value="/">/</option>
			</select>
			
			<input type="text" v-model="n2">
			
			<input type="button" value="=" @click="equealRsult" />
			
			<input type="text" v-model="result">
		</div>
	</body>
	<script>
		var vm=new Vue({
			el:"#app",
			data:{
				n1:0,
				n2:0,
				result:0,
				xuanze:"+"
			},
			methods:{
				equealRsult(){
					var str="parseInt(this.n1)"+this.xuanze+"parseInt(this.n2)";
					/*
					 * eval():将字符串解析并执行
					 */
					this.result=eval(str);
				}
			}
		});
	</script>
</html>